package com.iknow.xmpp.extention;

import com.iknow.xmpp.service.Friend;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;

public class IKnowUserProvider
  implements IQProvider
{
  private Friend parseFriend(XmlPullParser paramXmlPullParser, UserInfomationIQ paramUserInfomationIQ)
  {
    Friend localFriend = new Friend(paramUserInfomationIQ.getFieldValue("user_id") + "@" + "imiknow.com", paramUserInfomationIQ.getFieldValue("email"), paramUserInfomationIQ.getFieldValue("nickName"), paramUserInfomationIQ.getFieldValue("photoUrl"), paramUserInfomationIQ.getFieldValue("userFlag"), paramUserInfomationIQ.getFieldValue("signature"), paramUserInfomationIQ.getFieldValue("gender"), paramUserInfomationIQ.getFieldValue("favCount"), paramUserInfomationIQ.getFieldValue("wordCount"), paramUserInfomationIQ.getFieldValue("subscribeFlag"));
    localFriend.setLongitudeAndLatitude(Double.parseDouble(paramUserInfomationIQ.getFieldValue("longitude")), Double.parseDouble(paramUserInfomationIQ.getFieldValue("latitude")));
    localFriend.setTags(paramUserInfomationIQ.getFieldValue("userFlag"));
    return localFriend;
  }

  public IQ parseIQ(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    UserInfomationIQ localUserInfomationIQ = new UserInfomationIQ();
    localUserInfomationIQ.setType(IQ.Type.RESULT);
    int i = 0;
    while (true)
    {
      int j;
      do
      {
        int k;
        do
        {
          do
          {
            if (i != 0)
              return localUserInfomationIQ;
            j = paramXmlPullParser.next();
            if (j != 2)
              break label133;
          }
          while ((paramXmlPullParser.getName().equals("user")) || (!(paramXmlPullParser.getName().equals("item"))));
          k = paramXmlPullParser.getAttributeCount();
        }
        while (-1 == k);
        int l = 0;
        while (true)
        {
          while (l >= k)
          {
            localUserInfomationIQ.addFriend(parseFriend(paramXmlPullParser, localUserInfomationIQ));
            localUserInfomationIQ.clearAttributes();
          }
          localUserInfomationIQ.put(paramXmlPullParser.getAttributeName(l), paramXmlPullParser.getAttributeValue(l));
          label133: ++l;
        }
      }
      while ((j != 3) || (!(paramXmlPullParser.getName().equals("user"))));
      i = 1;
    }
  }
}